package com.itfreer.power.service.role;

import javax.ws.rs.DELETE;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.itfreer.form.api.BaseRestService;
import com.itfreer.form.api.BaseService;
import com.itfreer.power.entity.role.RoleEntity;

/**
 * 定义用户服务
 */
@Component
@Path("/role/")
public class RestRoleService extends BaseRestService<RoleEntity> {
	
	@Autowired
	private RoleService roleManage;
	
	@Override
	protected String getServiceName() {
		return "role";
	}
	
	/**
	 * 删除用户角色关系
	 * @param userId
	 * @param roleId
	 */
	@DELETE
	@Path("/delUserRole/{uid:.+}/{rid:.+}")
	@Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON)
	public void delUserRole(@PathParam("uid") String userId, @PathParam("rid") String roleId){
		roleManage.delUserRole(userId, roleId);
	}
	
	/**
	 * 添加用户角色关系
	 * @param userId
	 * @param roleId
	 */
	@POST
	@Path("/addUserRole/{uid:.+}/{rid:.+}")
	@Produces(javax.ws.rs.core.MediaType.APPLICATION_JSON)
	public void addUserRole(@PathParam("uid") String userId, @PathParam("rid") String roleId){
		roleManage.addUserRole(userId, roleId);
	}

	@Override
	protected BaseService<RoleEntity> getService() {
		return roleManage;
	}
}